s = str(input())
if s != s[::-1]:
print(len(s))
else:
if len(set(s)) == 1:
print(0)
else:
print(len(s)-1)
#include<bits/stdc++.h>
using namespace std;
typedef int li;
typedef long long int ll;
typedef unsigned long long int ul;
typedef double db;
//---------------------------------------------------------------------------------
typedef vector < li > vli;
typedef vector < ll > vll;
typedef set < li > sli;
typedef set < ll > sll;
typedef pair < pair<li, li>, li> pli;
typedef pair < ll, ll > pll;
typedef map < li,li > mli;
typedef map < ll,ll > mll;
typedef vector < pair < li, li > > vpi;
typedef vector < pair < ll, ll > > vpl;
typedef priority_queue<li> pqi;
typedef priority_queue<ll> pql;
//----------------------------------------------------------------------------------
#define Fast ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define tc int t;cin>>t;while(t--)
#define inp_(a,n) for(int i=0; i<n ;i++) cin>>a[i];
#define loop_(a,n) for(int i=0; i<n ;i++)
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
//----------------------------------------------------------------------------------
//-----------------------USER DEFINED FUNC--------------------------------//
/*
//Prime check
bool isPrime(int n)
{
if (n<2) return false;
if (n<=3) return true;
if (!(n%2) || !(n%3)) return false;
for (int i=5; i*i<=n; i+=6)
if (!(n%i) || !(n%(i+2))) return false;
return true;
}
//Greatest common divisor — GCD
ll gcd(ll a, ll b)
{
if (b==0) return a;
else return gcd(b, a%b);
}
//Least common multiple — LCM
int lcm(int a, int b)
{
return a*b/gcd(a,b);
}
//--------------------------------------Sieve_Of_Eratosthenes------------------------------//
const ll x=10000000+5;
bool prime[x];
vector<ll> kthprime;
void seive(){
memset(prime,true,sizeof(prime));
prime[0]=prime[1]=false;
for(ll i=2; i*i<=x; i++){
if(prime[i]){
for(ll j=i*i; j<=x; j+=i){
prime[j]=false;
}
}
}
for(ll i=2; i<=x; i++) {
if(prime[i]) kthprime.push_back(i);
}
// for(auto u:kthprime) cout<<u<<" ";
}
void SieveOfEratosthenes(int n)
{
bool prime[n + 1];
memset(prime, true, sizeof(prime));
for (int p = 2; p * p <= n; p++)
{
if (prime[p] == true)
{
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
// Print all prime numbers
for (int p = 2; p <= n; p++)
if (prime[p])
cout << p << " ";
}
//----------------------------------------------------------------------------------------//
ll findGCD(ll a[], ll n)//over an array
{
ll result = a[0];
for (int i = 1; i < n; i++)
{
result = gcd(a[i], result);
if(result == 1)
{
return 1;
}
}
return result;
}
//-----------------------------------------------------------------------------------------//
ll ub(vector<ll>&v, ll R)
{
ll left=0, right=v.size()-1, mid;
while(left<=right)
{
mid=(left+right)/2;
if(v[mid]>R) right=mid-1;
else left=mid+1;
}
return left;
}
ll lb(vector<ll>&v, ll R)
{
ll left=0, right=v.size()-1, mid;
while(left<=right)
{
mid=(left+right)/2;
if(v[mid]>=R) right=mid-1;
else left=mid+1;
}
return left;
}
//-----------------------------------------------------------------------------------------//
*\
///////////////////////////*****STARTING POINT*****/////////////////////////////////
void solve(){
string s,cs;
cin>>s;
cs = s;
sort(cs.begin(),cs.end());
if(cs[0]==cs[s.length()-1]) cout<<0;
else if(s[0]!=s[s.length()-1]) cout<<s.length();
else{
int f=0,l=s.length()-1,c=0;
for(int i=0; i<s.length()/2; i++){
if(s[f]!=s[l]) {c=1; break;}
f++;l--;
}
if(c) cout<<s.length();
else cout<<s.length()-1;
}
}
int main(){
Fast
//tc
solve();
}
///////////////////////////*****END OF CODE*****////////////////////////////////////
21. Merge Two Sorted Lists | 203. Remove Linked List Elements |
733. Flood Fill | 206. Reverse Linked List |
83. Remove Duplicates from Sorted List | 116. Populating Next Right Pointers in Each Node |
145. Binary Tree Postorder Traversal | 94. Binary Tree Inorder Traversal |
101. Symmetric Tree | 77. Combinations |
46. Permutations | 226. Invert Binary Tree |
112. Path Sum | 1556A - A Variety of Operations |
136. Single Number | 169. Majority Element |
119. Pascal's Triangle II | 409. Longest Palindrome |
1574A - Regular Bracket Sequences | 1574B - Combinatorics Homework |
1567A - Domino Disaster | 1593A - Elections |
1607A - Linear Keyboard | EQUALCOIN Equal Coins |
XOREQN Xor Equation | MAKEPAL Weird Palindrome Making |
HILLSEQ Hill Sequence | MAXBRIDGE Maximise the bridges |
WLDRPL Wildcard Replacement | 1221. Split a String in Balanced Strings |